<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

require(APPPATH . 'core/admin.php');

class Invitation extends Admin
{
    public function getPage()
    {
        return 'invitation';
    }

    public function send()
    {
        $email = $_POST['email'];
        $letter = $_POST['letter'];

        $this->load->helper('email');

        if (valid_email($email)) {
            $this->load->library('email');

            $this->email->from('support@kiemsoattam.com', 'KiemSoatTam Support');
            $this->email->to($email);
            $this->email->subject('Invitation FROM KiemSoatTam.vn');
            $this->email->message($letter);

            $this->email->send();

            redirect(site_url('invitation/index/common.ok'));
        } else {
            redirect(site_url('invitation/index/invitation.invalid'));
        }
    }
}